<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>OpenMesh: Mesh Decimation Framework</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="logo_align.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="rwth_vci_rgb.jpg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">OpenMesh
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('a04316.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Mesh Decimation Framework </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The mesh decimation framework has 3 building blocks.</p>
<ol type="1">
<li><a class="el" href="a04316.html#DecimaterAlg">The decimation algorithm</a></li>
<li><a class="el" href="a04316.html#DecimaterMod">Decimating Modules</a></li>
<li><a class="el" href="a04316.html#DecimaterHnd">Module Handles</a></li>
</ol>
<h1><a class="anchor" id="DecimaterAlg"></a>
The decimation algorithm</h1>
<p>The decimater (<a class="el" href="a02637.html" title="Decimater framework. ">OpenMesh::Decimater::DecimaterT</a>) provides the decimation algorithm, while the decimation modules provide the computational part. The modules compute a priority value due to some error metric, which is used by the decimater to feed a priority queue. The lower the error value, the more a potential collapse moves to the front of the queue. The one with the lowest error will always be the candidate for the next collapse.</p>
<p>This implementation does a halfedge collapse, hence simply collapsing one vertex into another connected by a halfedge.</p>
<dl class="section note"><dt>Note</dt><dd>The decimater ignores all 'locked' and 'deleted' vertices (see <a class="el" href="a01238.html#af600bbf2c3f55c90a2a64848f0547617" title="Status bits used by the Status class. ">OpenMesh::Attributes::StatusBits</a>)</dd></dl>
<dl class="section attention"><dt>Attention</dt><dd>The decimater sets temporarily the status bit 'tagged' and clears it after usage regardless of a previous state.</dd></dl>
<h1><a class="anchor" id="DecimaterLock"></a>
Block vertices from beeing touched by the Decimater</h1>
<p>You could mark vertices as locked, which should not be modified by the decimater.</p>
<div class="fragment"><div class="line"><span class="comment">// That might be already requested</span></div><div class="line">mesh_-&gt;request_vertex_status();</div><div class="line"></div><div class="line"><span class="comment">// Get an iterator over all halfedges</span></div><div class="line">Mesh::HalfedgeIter he_it, he_end=mesh_-&gt;halfedges_end();</div><div class="line"></div><div class="line"><span class="comment">// If halfedge is boundary, lock the corresponding vertices</span></div><div class="line"><span class="keywordflow">for</span> (he_it = mesh_-&gt;halfedges_begin(); he_it != he_end ; ++he_it)</div><div class="line">  <span class="keywordflow">if</span> (mesh_-&gt;is_boundary(*he_it)) {</div><div class="line">     mesh_-&gt;status(_mesh-&gt;to_vertex_handle(*he_it)).set_locked(<span class="keyword">true</span>);</div><div class="line">     mesh_-&gt;status(_mesh-&gt;from_vertex_handle(*he_it)).set_locked(<span class="keyword">true</span>);</div><div class="line">  }</div></div><!-- fragment --><h1><a class="anchor" id="DecimaterMod"></a>
Decimating Modules</h1>
<p>The vertex to be removed is determined by a decimation module, which has to be derived from <a class="el" href="a02661.html" title="Base class for all decimation modules. ">OpenMesh::Decimater::ModBaseT</a>. The framework supplies already a few decimation modules. But it's very easy to build your own (<a class="el" href="a02661.html">OpenMesh::Decimater::ModBaseT</a>). The most important function of a decimation module is <a class="el" href="a02661.html#acb81c6b9a752741fce2366ca605cd14c" title="Return collapse priority. ">OpenMesh::Decimater::ModBaseT::collapse_priority()</a>. It takes an <a class="el" href="a02633.html" title="Stores information about a halfedge collapse. ">OpenMesh::Decimater::CollapseInfoT</a> describing a potential halfedge collapse, and returns a value due to some error metric. The error value is used by the decimater to feed a priority queue. Collapses with low error will be executed first, and those with large error later. Of course a module computing the error quadric is provided (<a class="el" href="a02693.html" title="Mesh decimation module computing collapse priority based on error quadrics. ">OpenMesh::Decimater::ModQuadricT</a>).</p>
<p>This framework allows to use more than one decimation module with some restrictions. Since the error value is always normalized and sometimes very difficult to compare to other metrics, the framework allows only one non-binary module, i.e. a module computing a float value. Every further module must be a binary module, i.e. collapse_prioerity() returns <a class="el" href="a02661.html#a49500127c96591367298aa17e8527e44a2b521064f4abfdfb6eb5464308b6f6e7" title="indicates a legal collapse ">OpenMesh::Decimater::ModBaseT::LEGAL_COLLAPSE</a> or <a class="el" href="a02661.html#a49500127c96591367298aa17e8527e44afc88837943f46ccbf0ef35d3fcf9c5b1" title="indicates an illegal collapse ">OpenMesh::Decimater::ModBaseT::ILLEGAL_COLLAPSE</a>. In the algorithm the binary modules are evaluated first. If the evaluated collapse passes the test, then the non-binary module contributes to the decision step.</p>
<p>In some cases the module does not contribute anything to the decision engine of the decimater, but instead, e.g. simply collects information, while the decimater does it's work. For instance the module <a class="el" href="a02685.html" title="Collect progressive mesh information while decimating. ">OpenMesh::Decimater::ModProgMeshT</a> collects information from all collapses that have been done. This information can be used to generate progressive meshes as described in "Progressive meshes", Hoppe, 1996.</p>
<p>Provided decimation modules(Binary: B, Continuous: C, Special: X):</p>
<ul>
<li><a class="el" href="a02653.html" title="Use aspect ratio to control decimation. ">OpenMesh::Decimater::ModAspectRatioT</a> (B,C)</li>
<li><a class="el" href="a02665.html" title="Use edge length to control decimation. ">OpenMesh::Decimater::ModEdgeLengthT</a> (B,C)</li>
<li><a class="el" href="a02669.html" title="Use Hausdorff distance to control decimation. ">OpenMesh::Decimater::ModHausdorffT</a> (B)</li>
<li><a class="el" href="a02673.html" title="Lock one-ring around remaining vertex after a collapse to prevent further collapses of halfedges inci...">OpenMesh::Decimater::ModIndependentSetsT</a> (B)</li>
<li><a class="el" href="a02677.html" title="Use Normal deviation to control decimation. ">OpenMesh::Decimater::ModNormalDeviationT</a> (B,C)</li>
<li><a class="el" href="a02681.html" title="Decimating module to avoid flipping of faces. ">OpenMesh::Decimater::ModNormalFlippingT</a> (B)</li>
<li><a class="el" href="a02685.html" title="Collect progressive mesh information while decimating. ">OpenMesh::Decimater::ModProgMeshT</a> (X)</li>
<li><a class="el" href="a02693.html" title="Mesh decimation module computing collapse priority based on error quadrics. ">OpenMesh::Decimater::ModQuadricT</a> (B,C)</li>
<li><a class="el" href="a02697.html" title="Use Roundness of triangles to control decimation. ">OpenMesh::Decimater::ModRoundnessT</a> (B,C)</li>
</ul>
<h1><a class="anchor" id="DecimaterHnd"></a>
Module Handles</h1>
<p>Similar to properties the modules are represented outside the decimater by module handles. Before using the decimater a non-binary module must be registrated with the decimater.</p>
<p>See <a class="el" href="a04316.html#DecimaterExa">Basic Setup</a>.</p>
<h1><a class="anchor" id="DecimaterExa"></a>
Basic Setup</h1>
<p>The following small example show the basic steps to setup up a decimater:</p>
<div class="fragment"><div class="line"><span class="keyword">using namespace </span><a class="code" href="a01233.html">OpenMesh</a>;</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> <a class="code" href="a02377.html">TriMesh_ArrayKernelT&lt;&gt;</a>               <a class="code" href="a02385.html">Mesh</a>;</div><div class="line"><span class="keyword">typedef</span> Decimater::DecimaterT&lt;Mesh&gt;          Decimater;</div><div class="line"><span class="keyword">typedef</span> Decimater::ModQuadricT&lt;Mesh&gt;::Handle HModQuadric;</div><div class="line"></div><div class="line">Mesh        mesh;             <span class="comment">// a mesh object</span></div><div class="line">Decimater   decimater(mesh);  <span class="comment">// a decimater object, connected to a mesh</span></div><div class="line">HModQuadric hModQuadric;      <span class="comment">// use a quadric module</span></div><div class="line"></div><div class="line">decimater.add(hModQuadric); <span class="comment">// register module at the decimater</span></div><div class="line">std::cout &lt;&lt; decimater.module(hModQuadric).name() &lt;&lt; std::endl; <span class="comment">// module access</span></div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * since we need exactly one priority module (non-binary)</span></div><div class="line"><span class="comment"> * we have to call set_binary(false) for our priority module</span></div><div class="line"><span class="comment"> * in the case of HModQuadric, unset_max_err() calls set_binary(false) internally</span></div><div class="line"><span class="comment"> */</span></div><div class="line">decimater.module(hModQuadric).unset_max_err();</div><div class="line"></div><div class="line">decimater.initialize();</div><div class="line">decimater.decimate();</div><div class="line"></div><div class="line"><span class="comment">// after decimation: remove decimated elements from the mesh</span></div><div class="line">mesh.garbage_collection();</div></div><!-- fragment --> </div></div><!-- contents -->
</div><!-- doc-content -->
<hr>
<address>
<small>
<a href="http://www.rwth-graphics.de" style="text-decoration:none;">
</a>
Project <b>OpenMesh</b>, 
&copy;&nbsp; Computer Graphics Group, RWTH Aachen.
Documentation generated using 
<a class="el" href="http://www.doxygen.org/index.html">
<b>doxygen</b>
</a>.
</small>
</address>
</body>
</html>
